.org 0xE0158 ; Increase Funds

Increase_Funds:

	PUSH 	{R4-R5, LR}
	SUB		SP, SP, 4
	LDR 	R2, [Increase_Funds_1] 
	AND		R1, R1, 0x1F
	LDRSB	R1, [R2, R1]
	MOV		R5, 0
	CMP 	R1, 0								; Does play own any Properties?
	BEQ		Player_No_Properties

;-------------------------------------------------------------------------------	

	LDR 	R2, [Increase_Funds_2]
	LDR 	R1, [Increase_Funds_3]
	LDR 	R3, [R2, 0]
	LDR 	R2, [R1, 0]
	MOV 	R1, 0x98
	ADD 	R2, R3, R2, LSL 2
	MUL 	R4, R0, R1
	LDR 	R2, [R2, 0x48]
	
	MOV 	R1, Rank_Gold_Rush					; Rank: Gold Rush

	ADD 	R0, R2, 0x5000	
	LDR 	R0, [R0, 0xA58]
	LDR 	R2, [R2, 0x78]

	ADD 	R0, R0, R4
	ADD 	R0, R0, 0x74
	ADD 	R5, R5, R2
	
	BL 		Check_Skills_Equipped				; Check the Skill is equipped
		
	CMP 	R0, 0								; Does CO use that skill?
	
	LDR 	R1, [Increase_Funds_2]
	LDR 	R0, [Increase_Funds_3]
	LDR 	R2, [R1, 0]
	LDR 	R0, [R0, 0]
	
	MOV 	R1, CO_Extra_Funds					; Skill: Extra Funds
	
	ADD 	R0, R2, R0, LSL 2
	LDR 	R0, [R0, 0x48]	
	
	ADDNE 	R5, R5, 100							; If CO use skill, +100 income

	ADD 	R0, R0, 0x5000	
	LDR 	R0, [R0, 0xA58]
	ADD 	R0, R0, R4
	ADD 	R0, R0, 0x74
	
	BL 		Check_Skills_Equipped				; Check the Skill is equipped
	
	CMP 	R0, 0								; Does CO use that skill?
	ADDNE 	R5, R5, 100							; If CO use skill, +100 income
	
;-------------------------------------------------------------------------------

Player_No_Properties:
	
	MOV 	R0, R5
	ADD		SP, SP, 4
	POP 	{R4-R5, LR}
	
	BX 		LR

;-------------------------------------------------------------------------------		

Increase_Funds_1:
	.dw 0x022F45D8

Increase_Funds_2:
	.dw Reg1_Skill
	
Increase_Funds_3:
	.dw Reg2_Skill



